%{
#include <stdio.h>
#include <string.h>
extern FILE * yyin;

#define Print(Type,Star,Name) printf("@property (nonatomic, retain) %s %s%s;\n@synthesize %s;\n",Type,Star,Name,Name);
 
%}


%union
 {
  int number;
  char *string;
 }

%token <string> WORD
%token AT COLON INTERFACE LB RB IBOUTLET
%token STAR

%%

All:
| All Class
;

Class:
AT INTERFACE WORD ParentClass LB expressions RB
;

ParentClass:
| COLON WORD
;

expressions:
expression
|expressions expression
;
expression:
|WORD WORD  {Print($1,"",$2);}
|IBOUTLET WORD WORD {Print($2,"",$3);}
|WORD STAR WORD {Print($1,"*",$3);}
|IBOUTLET WORD STAR WORD {Print($2,"*",$4);}
;
%%

int yywrap()
{

  return 1;
}

int main(void) {
  int yydebug = 1;
  yyin = fopen("test.txt","r"); 
  yyparse();
  fclose(yyin);
  return 0;
}
